package coroutines.coroutine.context

import kotlin.coroutines.AbstractCoroutineContextElement
import kotlin.coroutines.CoroutineContext

class CustomCoroutineExceptionHandler(val onErrorAction: (Throwable) -> Unit) : AbstractCoroutineContextElement(Key) {
    companion object Key : CoroutineContext.Key<CustomCoroutineExceptionHandler>

    fun onError(error: Throwable) {
        error.printStackTrace()

        onErrorAction(error)
    }
}